from ui_auto2.public.pages.basepage import BsaePage
from selenium import webdriver
from time import sleep
from ui_auto2.public.utils.read_ini import Read_ini
import os
from ui_auto2.config.config import *
from ui_auto2.data.input_elem import Elem_Iput
import unittest

file=os.path.join(data_path,"data.ini")
r=Read_ini(file)
url=r.read_ini_data("test_data","url")
username=r.read_ini_data("test_data","username")
password=r.read_ini_data("test_data","password")
class Test_Login(BsaePage):
    @classmethod
    def setUpClass(cls) -> None:
        driver=webdriver.Chrome()
        BsaePage.set_driver(driver)
    @classmethod
    def tearDownClass(cls) -> None:
        sleep(2)
    def test_login(self):
        browser=BsaePage.get_driver()
        browser.get(url)
        BsaePage.max()
        elem1=BsaePage.search_elem(Elem_Iput.cms_account_input)
        BsaePage.sendkeys(elem1,username)
        elem2=BsaePage.search_elem(Elem_Iput.cms_passwd_input)
        BsaePage.sendkeys(elem2,password)
        elem3=BsaePage.search_elem(Elem_Iput.cms_loginbtn_input)
        BsaePage.click(elem3)
        try:
            elem4=BsaePage.search_elem(Elem_Iput.desk_top_input)
            value=BsaePage.text(elem4)
            self.assertEqual(value,"我的桌面")
        except Exception as e:
            BsaePage.shoot_png("D:/error.png")
        finally:
            pass
if __name__ == '__main__':
    unittest.main()



